PyData Northern Utah | ASC Innovation Lab
A Python environment is composed of the Python version and library versions (including dependencies)
It is not uncommon for different projects to require different Python versions and different library versions
It is not uncommon for different projects to require different Python versions and different library versions
A Python virtual environment (a.k.a., a project environment) is a self-contained, project-specific environment
Project environments can be reproduced on another machine by you (including future you) or someone else
Project environments can be reproduced on another machine by you (including future you) or someone else
If you need to reproduce something about your machine beyond your code, Python version, and library versions, you’ll want to use a container
uv?uv is an extremely fast Python package and project manager, written in Rust
conda, pip, poetry, pyenv, virtualenv, etc.uvGet started by installing uv via the command line (i.e., the programming interface into your OS itself)
macOS and Linux via Terminal
Windows via PowerShell
Restart your command line and run uv to verify it has been installed
Once you have uv installed, it’s easy to install and manage Python different versions from the command line
uv python installuv python install 3.13.4uv python listuv python finduv python uninstall 3.13.4There’s lots more uv can do to manage Python versions
Using the command line or a code editor (i.e., VS Code, Cursor, Positron, etc.), create or navigate to a project directory, preferably one that is not being synced to the cloud via OneDrive, iCloud, etc.
macOS and Linux via Terminal
Windows via PowerShell
Dragging a folder from your finder/file explorer and dropping it into the terminal/shell will paste its file path
Run uv init to initialize a project environment in your project directory and create a pyproject.toml file, the Python standard for defining configurations for a project, along with
.gitignore is a hidden file for turning your project directory into a Git repository.python-version is a hidden file that specifies the version of Python for the projectmain.py is a Python script you can use or deleteREADME.md is a markdown file that is also used in Git repositories that you can use or deleteWith the project environment initialized, we can now install libraries, like uv add polars, which install the Polars library along with any dependecies, along with
That’s it! You now have a project environment managed by uv and can go ahead and use your favorite code editor to run Python code
uv add <library>, the uv.lock file is automatically updateduv run automatically installs any missing libraries from the uv.lock filerequirements.txt, run uv export --format requirements.txtpylock.toml, run uv export -o pylock.tomlAnd there’s a lot more thatn uv can do